package com.sxm.yiwei.activitis;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;
import com.sxm.yiwei.utils.InternetAddressUtis;

public class WEBXActivity extends BaseActivity implements View.OnClickListener {

    private WebView web;
    private ImageView back;
    private TextView title;
    private ImageView backmain;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webx);
        Intent intent = getIntent();
        String from = intent.getStringExtra("from");
        String url = intent.getStringExtra("url");
        initWebView();
        if (from.equals("hot")){
            title.setText("禁止发布协议");
        }else if (from.equals("hope")){
            title.setText("心语心愿说明协议");
        }else if (from.equals("buy")){
            title.setText("服务购买协议");
        }else if (from.equals("yivi")){
            title.setText("一喂员协议");
        }else if (from.equals("yivier")){
            title.setText("一喂员等级说明");
        }else if (from.equals("no")){
            title.setText("一喂员须知");
        }else if (from.equals("guanli")){
            title.setText("一喂员管理条例");
        }else if (from.equals("problem")){
            title.setText("常见问题");
        }else if (from.equals("open")){
            title.setText("保证金缴纳协议");
        }else {}
        webInit(url);
    }

    private void webInit(String url) {
        web.getSettings().setJavaScriptEnabled(true);
        web.loadUrl(InternetAddressUtis.Url+url);
    }

    private void initWebView() {
        web = (WebView) findViewById(R.id.web_web);
        backmain = (ImageView) findViewById(R.id.web_backmain);
        backmain.setOnClickListener(this);
        title = (TextView) findViewById(R.id.web_title);
    }

    @Override
    public void onClick(View v) {
        startActivity(new Intent(WEBXActivity.this, MainActivity.class));
        AppManager.getAppManager().finishAllActivity();

    }
}
